package com.luzh.myspring.bean.model;

import com.luzh.myspring.bean.Person;
import com.luzh.myspring.beans.factory.annotation.Autowired;
import com.luzh.myspring.beans.factory.annotation.Qualifier;
import com.luzh.myspring.beans.factory.annotation.Value;
import com.luzh.myspring.stereotype.Component;



@Component
public class User implements Person {
    @Value("小红")
    private String name;
    @Autowired
    @Qualifier("book")
    private Book book;

    public User() {
    }

    public User(String name) {
        this.name = name;
    }

    @Override
    public void say(String s){
        System.out.println(name+" say "+s);
    }
    @Override
    public void read(Book book){
        System.out.println(name+" read a book "+book.getName());
    }

    public void initMethod(){
        System.out.println(name+"初始化");
    }

    public void destroyMethod(){
        System.out.println(name+"销毁");
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Book getBook() {
        return book;
    }

    public void setBook(Book book) {
        this.book = book;
    }

    public String print() {
        return "User{" +
                "name='" + name + '\'' +
                ", book=" + book +
                '}';
    }
}
